//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2007 CORE Solutions Limited
// All rights reserved.
// PROPRIETARY AND CONFIDENTIAL INFORMATION.
// Use is subject to license terms.
//
// FUNCTION ID      :   MASTER_DEPARTMENT
// AUTHOR           :   Ray Guo 
// DATE CREATE      :   2007/07/11
// DESCRIPTION      :   a SEARCH FORM file for the function, MASTER_DEPARTMENT
//                  :   
//                  :   
//                  :   
//
// MODIFICATION HISTORY:
// DATE         AUTHOR          VERSION NO.         COMMENT
// -----------  --------------  ------------------  -------------------
// 2007/07/11   Ray Guo         1.0                 source is generated.
//
//
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

package com.erp.app.setup.dept.web;

import java.util.Iterator;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

import com.erp.app.common.ProjectConstants;
import com.erp.app.common.query.BeanQuery;
import com.erp.app.util.web.BeanValidator;
import com.erp.framework.controller.form.SimpleSearchStyleFormTemplate;
import com.erp.framework.util.logger.Logger;

/**
* <p>A <strong>SearchForm</strong> is a JavaBean which provides property
* getter and setter methods for all of the bean properties, and implements
* <code>Serializable</code>, as required by the JavaBean specification
* The main purpose for this bean is to get the user search criteria input
* from the web browsers.
*
* @author          Ray Guo 
* @version 1.0     2007/07/11
* @since           FrameWork 1.0
*
*/

// Note:
// Currently only generates the first -1 fields of a table
// (excluding the COMPANY_CODE field).
// However, this number can be set in GenConstants.NO_CRITERIA

public class DeptSearchForm extends SimpleSearchStyleFormTemplate {

	//Searching Criteria Attributes (DB Table Name: T_MASTER_DEPARTMENT)
	private String srchCompanyCode;                                                                    //DB Column Name: COMPANY_CODE
	private String srchHdrStatus;                                                                      //DB Column Name: STATUS
	private String srchDeptCodeFr;                                                                     //DB Column Name: DEPT_CODE
	private String srchDeptCodeTo;                                                                     //DB Column Name: DEPT_CODE
	private String srchHdrDeptNameFr;                                                                  //DB Column Name: DEPT_NAME
	private String srchHdrDeptNameTo;                                                                  //DB Column Name: DEPT_NAME
	private String srchHdrGroupCodeFr;                                                                 //DB Column Name: GROUP_CODE
	private String srchHdrGroupCodeTo;                                                                 //DB Column Name: GROUP_CODE
	private String srchHdrBrandCodeFr;                                                                 //DB Column Name: BRAND_CODE
	private String srchHdrBrandCodeTo;                                                                 //DB Column Name: BRAND_CODE
	private String srchHdrCustCodeFr;                                                                  //DB Column Name: CUST_CODE
	private String srchHdrCustCodeTo;                                                                  //DB Column Name: CUST_CODE
	private String srchHdrDivisionCodeFr;                                                              //DB Column Name: DIVISION_CODE
	private String srchHdrDivisionCodeTo;                                                              //DB Column Name: DIVISION_CODE
	private String srchHdrOutletFr;                                                                    //DB Column Name: OUTLET
	private String srchHdrOutletTo;                                                                    //DB Column Name: OUTLET
	private String srchHdrIsUsFr;                                                                      //DB Column Name: IS_US
	private String srchHdrIsUsTo;                                                                      //DB Column Name: IS_US
	private String srchHdrIsMerchandisingDepartmentFr;                                                 //DB Column Name: IS_MERCHANDISING_DEPARTMENT
	private String srchHdrIsMerchandisingDepartmentTo;                                                 //DB Column Name: IS_MERCHANDISING_DEPARTMENT

	private String editMaster_departmentCode;


	/**
	* Validate the properties that have been set for this non-HTTP request,
	* and return an <code>ActionErrors</code> object that encapsulates any
	* validation errors that have been found.  If no errors are found, return
	* <code>null</code> or an <code>ActionErrors</code> object with no
	* recorded error messages.
	* <p>
	* The default implementation attempts to forward to the HTTP version of
	* this method.
	*
	* @param      the action errors array
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	public void validateSearch(ActionErrors errors) {

		try {

		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	/**
	* Validate the properties that have been set for this non-HTTP request,
	* and return an <code>ActionErrors</code> object that encapsulates any
	* validation errors that have been found.  If no errors are found, return
	* <code>null</code> or an <code>ActionErrors</code> object with no
	* recorded error messages.
	* <p>
	* The default implementation attempts to forward to the HTTP version of
	* this method.
	*
	* @param      mapping      the action mapping
	* @param      formIn       the action form
	* @param      request      the http request
	* @param      response     the http response
	* @param      errors       the action errors array
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	public void moreValidateSearch(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {


		BeanValidator validator = new BeanValidator();
//		validator.validate(mapping, formIn, request, response, errors);
	}

	/**
	* Converts to a string representing the data in this object.
	* A new <code>String</code> object is allocated and initialized to 
	* contain the character sequence currently represented by this 
	* object. This <code>String</code> is then returned. Subsequent 
	* changes to this object do not affect the contents of the 
	* <code>String</code>. 
	*
	* @return     a string representation of the object.
	* @see        java.lang.Object#toString()
	* @author     Ray Guo 
	* @since      Framework 1.0
	*/
	public String toString() {
		String pkStr = "PK: {srchDeptCodeFr = " + this.srchDeptCodeFr
			+ "\n, srchDeptCodeTo = " + this.srchDeptCodeTo + "}\n";

		String colStr = "COL: {srchHdrDeptNameFr = " + this.srchHdrDeptNameFr
			+ "\n, srchHdrDeptNameTo = " + this.srchHdrDeptNameTo
			+ "\n, srchHdrGroupCodeFr = " + this.srchHdrGroupCodeFr
			+ "\n, srchHdrGroupCodeTo = " + this.srchHdrGroupCodeTo
			+ "\n, srchHdrBrandCodeFr = " + this.srchHdrBrandCodeFr
			+ "\n, srchHdrBrandCodeTo = " + this.srchHdrBrandCodeTo
			+ "\n, srchHdrCustCodeFr = " + this.srchHdrCustCodeFr
			+ "\n, srchHdrCustCodeTo = " + this.srchHdrCustCodeTo
			+ "\n, srchHdrDivisionCodeFr = " + this.srchHdrDivisionCodeFr
			+ "\n, srchHdrDivisionCodeTo = " + this.srchHdrDivisionCodeTo
			+ "\n, srchHdrOutletFr = " + this.srchHdrOutletFr
			+ "\n, srchHdrOutletTo = " + this.srchHdrOutletTo
			+ "\n, srchHdrIsUsFr = " + this.srchHdrIsUsFr
			+ "\n, srchHdrIsUsTo = " + this.srchHdrIsUsTo
			+ "\n, srchHdrIsMerchandisingDepartmentFr = " + this.srchHdrIsMerchandisingDepartmentFr
			+ "\n, srchHdrIsMerchandisingDepartmentTo = " + this.srchHdrIsMerchandisingDepartmentTo + "}\n";

		String mandatoryStr = "{srchCompanyCode = " + this.srchCompanyCode
			+ "\n, srchHdrStatus = " + this.srchHdrStatus
			+ "}\n";

		String editStr = "{editMaster_departmentCode = " + this.editMaster_departmentCode + "}";

		return "toString() is:\n" + mandatoryStr + pkStr + colStr + editStr;
	}

	////////////////////////////////////////////////////////////////////////////////
	//Generated Accessors (get/set methods) for searching criterias
	////////////////////////////////////////////////////////////////////////////////

	public String getSrchCompanyCode() {
		return this.srchCompanyCode;
	}

	public String getSrchHdrStatus() {
		return this.srchHdrStatus;
	}

	public String getSrchDeptCodeFr() {
		return this.srchDeptCodeFr;
	}

	public String getSrchDeptCodeTo() {
		return this.srchDeptCodeTo;
	}

	public String getSrchHdrDeptNameFr() {
		return this.srchHdrDeptNameFr;
	}

	public String getSrchHdrDeptNameTo() {
		return this.srchHdrDeptNameTo;
	}

	public String getSrchHdrGroupCodeFr() {
		return this.srchHdrGroupCodeFr;
	}

	public String getSrchHdrGroupCodeTo() {
		return this.srchHdrGroupCodeTo;
	}

	public String getSrchHdrBrandCodeFr() {
		return this.srchHdrBrandCodeFr;
	}

	public String getSrchHdrBrandCodeTo() {
		return this.srchHdrBrandCodeTo;
	}

	public String getSrchHdrCustCodeFr() {
		return this.srchHdrCustCodeFr;
	}

	public String getSrchHdrCustCodeTo() {
		return this.srchHdrCustCodeTo;
	}

	public String getSrchHdrDivisionCodeFr() {
		return this.srchHdrDivisionCodeFr;
	}

	public String getSrchHdrDivisionCodeTo() {
		return this.srchHdrDivisionCodeTo;
	}

	public String getSrchHdrOutletFr() {
		return this.srchHdrOutletFr;
	}

	public String getSrchHdrOutletTo() {
		return this.srchHdrOutletTo;
	}

	public String getSrchHdrIsUsFr() {
		return this.srchHdrIsUsFr;
	}

	public String getSrchHdrIsUsTo() {
		return this.srchHdrIsUsTo;
	}

	public String getSrchHdrIsMerchandisingDepartmentFr() {
		return this.srchHdrIsMerchandisingDepartmentFr;
	}

	public String getSrchHdrIsMerchandisingDepartmentTo() {
		return this.srchHdrIsMerchandisingDepartmentTo;
	}

	public String getEditMaster_departmentCode() {
		return this.editMaster_departmentCode;
	}

	public void setSrchCompanyCode(String srchCompanyCode) {
		this.srchCompanyCode = srchCompanyCode;
	}

	public void setSrchHdrStatus(String srchHdrStatus) {
		this.srchHdrStatus = srchHdrStatus;
	}

	public void setSrchDeptCodeFr(String srchDeptCodeFr) {
		this.srchDeptCodeFr = srchDeptCodeFr;
	}

	public void setSrchDeptCodeTo(String srchDeptCodeTo) {
		this.srchDeptCodeTo = srchDeptCodeTo;
	}

	public void setSrchHdrDeptNameFr(String srchHdrDeptNameFr) {
		this.srchHdrDeptNameFr = srchHdrDeptNameFr;
	}

	public void setSrchHdrDeptNameTo(String srchHdrDeptNameTo) {
		this.srchHdrDeptNameTo = srchHdrDeptNameTo;
	}

	public void setSrchHdrGroupCodeFr(String srchHdrGroupCodeFr) {
		this.srchHdrGroupCodeFr = srchHdrGroupCodeFr;
	}

	public void setSrchHdrGroupCodeTo(String srchHdrGroupCodeTo) {
		this.srchHdrGroupCodeTo = srchHdrGroupCodeTo;
	}

	public void setSrchHdrBrandCodeFr(String srchHdrBrandCodeFr) {
		this.srchHdrBrandCodeFr = srchHdrBrandCodeFr;
	}

	public void setSrchHdrBrandCodeTo(String srchHdrBrandCodeTo) {
		this.srchHdrBrandCodeTo = srchHdrBrandCodeTo;
	}

	public void setSrchHdrCustCodeFr(String srchHdrCustCodeFr) {
		this.srchHdrCustCodeFr = srchHdrCustCodeFr;
	}

	public void setSrchHdrCustCodeTo(String srchHdrCustCodeTo) {
		this.srchHdrCustCodeTo = srchHdrCustCodeTo;
	}

	public void setSrchHdrDivisionCodeFr(String srchHdrDivisionCodeFr) {
		this.srchHdrDivisionCodeFr = srchHdrDivisionCodeFr;
	}

	public void setSrchHdrDivisionCodeTo(String srchHdrDivisionCodeTo) {
		this.srchHdrDivisionCodeTo = srchHdrDivisionCodeTo;
	}

	public void setSrchHdrOutletFr(String srchHdrOutletFr) {
		this.srchHdrOutletFr = srchHdrOutletFr;
	}

	public void setSrchHdrOutletTo(String srchHdrOutletTo) {
		this.srchHdrOutletTo = srchHdrOutletTo;
	}

	public void setSrchHdrIsUsFr(String srchHdrIsUsFr) {
		this.srchHdrIsUsFr = srchHdrIsUsFr;
	}

	public void setSrchHdrIsUsTo(String srchHdrIsUsTo) {
		this.srchHdrIsUsTo = srchHdrIsUsTo;
	}

	public void setSrchHdrIsMerchandisingDepartmentFr(String srchHdrIsMerchandisingDepartmentFr) {
		this.srchHdrIsMerchandisingDepartmentFr = srchHdrIsMerchandisingDepartmentFr;
	}

	public void setSrchHdrIsMerchandisingDepartmentTo(String srchHdrIsMerchandisingDepartmentTo) {
		this.srchHdrIsMerchandisingDepartmentTo = srchHdrIsMerchandisingDepartmentTo;
	}

	public void setEditMaster_departmentCode(String editMaster_departmentCode) {
		this.editMaster_departmentCode = editMaster_departmentCode;
	}

	////////////////////////////////////////////////////////////////////////////////
	//Other Accessors (get/set methods)
	////////////////////////////////////////////////////////////////////////////////
	public Iterator getSrchHdrBrandCodeFrValues(){
		return this.getTemplate().getComboboxValues(new BeanQuery("SELECT BRAND_CODE, BRAND_NAME"
    			+ " FROM T_BRAND_HDR T WHERE T.COMPANY_CODE = '" + this.getSrchCompanyCode() + "'").setModel(this));
	}
	
	public Iterator getSrchHdrIsUsFrValues(){
		return this.getTemplate().getComboboxValues(new BeanQuery("SELECT CONSTANT_CODE, CONSTANT_NAME"
    			+ " FROM T_SYS_CONSTANTS T WHERE T.TYPE = '" + ProjectConstants.CONSTANT_TYPE_YES_NO + "'").setModel(this));
	}
	public Iterator getSrchHdrIsMerchandisingDepartmentFrValues(){
		return this.getTemplate().getComboboxValues(new BeanQuery("SELECT CONSTANT_CODE, CONSTANT_NAME"
    			+ " FROM T_SYS_CONSTANTS T WHERE T.TYPE = '" + ProjectConstants.CONSTANT_TYPE_YES_NO + "'").setModel(this));
	}
	public Iterator getHdrIsUsValues(){
		return this.getTemplate().getComboboxValues(new BeanQuery("SELECT CONSTANT_CODE, CONSTANT_NAME"
    			+ " FROM T_SYS_CONSTANTS T WHERE T.TYPE = '" + ProjectConstants.CONSTANT_TYPE_YES_NO + "'").setModel(this));
	}
	
	public Iterator getHdrIsMerchandisingDepartmentValues(){
		return this.getTemplate().getComboboxValues(new BeanQuery("SELECT CONSTANT_CODE, CONSTANT_NAME"
    			+ " FROM T_SYS_CONSTANTS T WHERE T.TYPE = '" + ProjectConstants.CONSTANT_TYPE_YES_NO + "'").setModel(this));
	}
	
	public Iterator getHdrBrandCodeValues(){
		return this.getTemplate().getComboboxValues(new BeanQuery("SELECT BRAND_CODE, BRAND_NAME"
    			+ " FROM T_BRAND_HDR T WHERE T.COMPANY_CODE = '" + this.getSrchCompanyCode() + "'").setModel(this));
	}
}
